import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { FinanceProfitEntity } from '../../entity/profit';
import { FinanceProfitService } from '../../service/profit';
import { StoreStoreEntity } from '../../../store/entity/store';
import { OrderOrderEntity } from '../../../order/entity/order';

/**
 * 分润记录
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: FinanceProfitEntity,
  service: FinanceProfitService,
  pageQueryOp: {
    fieldEq: ['a.agentId', 'a.storeId'],
    fieldLike: [{ column: 'a.profitStatus', requestParam: 'profitStatus' }],
    select: ['a.*', 'b.agentName', 'c.storeName', 'd.orderNo'],
    join: [
      {
        entity: StoreStoreEntity,
        alias: 'c',
        condition: 'a.storeId = c.id',
      },
      {
        entity: OrderOrderEntity,
        alias: 'd',
        condition: 'a.orderId = d.id',
      },
    ],
  },
})
export class AppFinanceProfitController extends BaseController {
  @Inject()
  financeProfitService: FinanceProfitService;
}
